#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,V;
int cs[10005];
int f[10005],f1[10005];
struct node{
    int d,v,a;
}ch[10005];
double jsd(int q,int w,int e){
    if(w==0){
        return q;
    }
    return sqrt(e*2*w+q*q);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
          cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++){
            cin>>ch[i].d>>ch[i].v>>ch[i].a;
        }
        for(int i=1;i<=m;i++){
            cin>>cs[i];
        }
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(cs[i]>=ch[j].d&&jsd(ch[j].v,ch[j].a,cs[i]-ch[j].d)>V){
                    cout<<jsd(ch[j].v,ch[j].a,cs[i])<<endl;
                    cout<<j<<" "<<cs[i]<<endl;
                    f[i]+=1;
                    f1[j]=1;
                }
            }
        }
        int sum=0,sum2=3;
        for(int i=1;i<=n;i++){
            sum+=f1[i];
        }
        if(sum==0) sum2=m;
        cout<<sum<<" "<<sum2;
    }
    return 0;
}
